<?php
include('config.php');
$name = isset($_POST['name']) ? trim($_POST['name']) : '';
$number = isset($_POST['number']) ? trim($_POST['number']) : '';
$info = isset($_POST['info']) ? $_POST['info'] : '';
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
$where = "guest_id={$id}";
$time = time();
$array = array('guest_tel'=>$number,'guest_info'=>$info,'guest_name'=>$name,'create_time'=>$time);
$res = $mysql->selectlist("guest"," guest_tel='{$number}'");

if($res){
	if($res[0]['guest_id'] == $id && $res[0]['guest_name']==$name && $res[0]['guest_info']==$info){
		echo 0;
	}elseif($res[0]['guest_id']!=$id){
			echo -2;
	}else{
		$rs = $mysql->update('guest',$where,$array);
		echo 1;
	}
}else{
	$rs = $mysql->update('guest',$where,$array);
	echo 1;
}